import { getComments } from '@/api/comment'
const state = {
  commentList: {}
}
const getters = {

}
const mutations = {
  GETCOMMENTS (state, Videos) {
    state.commentList = Videos
  },
  //   点赞修改数量
  APPROVE (state, data) {
    state.commentList[data.index].beLike = data.beLike
    if (data.beLike) {
      state.commentList[data.index].liked = state.commentList[data.index].liked + 1
    } else {
      state.commentList[data.index].liked = state.commentList[data.index].liked - 1
    }
  }
}
const actions = {
  async getComments ({ commit }, mId) {
    const result = await getComments(mId)
    commit('GETCOMMENTS', result.data)
  },
  Approve ({ commit }, data) {
    commit('APPROVE', data)
  }
}
export default ({
  namespaced: true,
  state,
  getters,
  mutations,
  actions
})
